<?php
	date_default_timezone_set("Asia/Singapore");
	$raidTime1 = mktime(21, 30, 00, 10, 27, 2010);
	$t1 = new DateTime("@$raidTime1");
	
	$raidTime2 = mktime(21, 30, 00, 10, 28, 2010);
	$t2 = new DateTime("@$raidTime2");
	
	
	$tzlist = DateTimeZone::listIdentifiers();
	//print_r($tzlist);
	$tzmap = array();
	foreach ($tzlist as $id=>$tz)
	{
		$tok = strtok($tz, "/");
		$name = $tok;
		$prefix = $tok;
		$tok = strtok("/");
		if ($tok !== false) {
			$name = $tok;
			$tok = strtok("/");
			while ($tok !== false) {
				$name .= "/" . $tok;
				$tok = strtok("/");
			}
			$tzmap[$prefix][] = $name;
		} else {
			//this is UTC
		}
	}
	
	function getTime1($id)
	{
		global $t1;
		$refTZ = new DateTimeZone($id);
		$t1->setTimeZone($refTZ);
		return $t1->format("h:i:s A D");
	}
	
	function getTime2($id)
	{
		global $t2;
		$refTZ = new DateTimeZone($id);
		$t2->setTimeZone($refTZ);
		return $t2->format("h:i:s A D");
	}
	//print_r($tzmap);
	/*
	$refTZ = new DateTimeZone("GMT"); //01:30 PM Wed and 01:30 PM Thu
	$refTZ = new DateTimeZone("Australia/Sydney"); //12:30 AM Thu and 12:30 AM Fri
	print $t1->format("r") . "\n";
	$t1->setTimeZone($refTZ);
	print $t1->format("r") . "\n";
	*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-EN">
<head>
	<script src="jquery-1.2.1.min.js" type="text/javascript"></script>
	<script src="menu.js" type="text/javascript"></script>
	<link rel="stylesheet" type="text/css" href="style.css" />
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>Protege Guild Raid Timings</title>
	<!--[if lt IE 8]>
   <style type="text/css">
   li a {display:inline-block;}
   li a {display:block;}
   </style>
   <![endif]-->
	<script language="javascript">
	function boxOffHover(box) {
	box.style.background='#EEE';
	}

	function boxOnHover(box) {
	box.style.background='#00CCFF';
	}
	</script>
</head>
<body>
	<h1>Protege Guild Raid Timings</h1>
	<div id="loading_msg"><i>Loading...</i></div>
	<div id="container_div" style="display: none">
	<ul id="menu1" class="menu">
		<?php
		foreach ($tzmap as $prefix=>$idlist)
		{
			?>
			<li>
				<a href="#"><?php echo $prefix?></a>
				<ul>
					<?php
					foreach ($idlist as $id)
					{
						?>
						<li><div class="tzrow" onmouseover="boxOnHover(this);" onmouseout="boxOffHover(this);"><b><?php echo $id?></b> <?php echo getTime1($prefix . "/" . $id);?> &amp; <?php echo getTime2($prefix . "/" . $id);?></div></li>
						<?php
					}
					?>
				</ul>
			</li>
			<?php
		}
		?>
	</ul>
	</div>
</body>
</html>